package com.wzy.content.api;

import com.wzy.content.model.dto.CoursePreviewDto;
import com.wzy.content.service.PreviewPublishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Author wzy
 * @Date 2024/1/18 12:26
 * @description: 课程预览和发布接口
 */
@Api(tags = "课程预览和发布接口",value = "课程预览和发布接口")
@Controller
public class PreviewPublishController {
    @Autowired
    private PreviewPublishService previewPublishService;
    @ApiOperation("课程预览接口")
    @GetMapping("/coursepreview/{courseId}")
    public ModelAndView preview(@PathVariable("courseId") Long courseId){

        //获得课程预览信息
        CoursePreviewDto coursePreviewInfo = previewPublishService.getCoursePreviewInfo(courseId);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("model",coursePreviewInfo);
        modelAndView.setViewName("course_template");
        return modelAndView;
    }

    @ApiOperation("课程提交审核接口")
    @ResponseBody
    @PostMapping("/courseaudit/commit/{courseId}")
    public void commitAudit(@PathVariable("courseId") Long courseId){
        Long companyId = 1232141425L;
        previewPublishService.commitAudit(companyId,courseId);
    }
    @ApiOperation("课程发布接口")
    @ResponseBody
    @PostMapping("/coursepublish/{courseId}")
    public void publishCourse(@PathVariable("courseId") Long courseId){
        Long companyId = 1232141425L;
        previewPublishService.publishCourse(companyId,courseId);
    }

}
